Object-oriented programming
part 24/57 · 94.0 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
An object's methods can access the object's data. Many programming languages use a special word, like this or self, to refer to the current object. In languages that support open recursion, a method in an object can call other methods in the same object, including itself, using this special word. This allows a method in one class to call another method defined later in a subclass, a feature known as late binding.
Design patterns
Design patterns are common solutions to problems in software design. Some design patterns are especially useful for OOP, and design patterns are typically introduced in an OOP context.
Object patterns
The following are notable software design patterns for OOP objects.cite-ref-r-c-martin-51-0[51]
• Function object: Class with one main method that acts like an anonymous function (in C++, the function operator, operator())
• Immutable object: does not change state after creation
• First-class object: can be used without restriction
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────